package com.seeyon.apps.ssoAndDoc.utils;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

public class StreamGobbler extends Thread{
	
	private static final Log LOGGER = LogFactory.getLog(StreamGobbler.class);

	InputStream is;
	String type;

	public StreamGobbler(InputStream is, String type) {
		this.is = is;
		this.type = type;
	}

	public void run() {
		try {
			InputStreamReader isr = new InputStreamReader(is, "utf-8");
			BufferedReader br = new BufferedReader(isr);
			String line = null;
			while ((line = br.readLine()) != null) {
				LOGGER.info(type + ">" + line);
			}
		} catch (Exception e) {
			LOGGER.error("调用转换工具异常", e);
		}
	}
}

